﻿#include "ssShaderAttrib.h"


namespace StarSeeker
{

ssShaderAttribute::ssShaderAttribute()
{
	m_size = 0;
	m_type = 0;
	m_glslID = -1;
	m_stride = 0;
	m_data = 0;
}

void ssShaderAttribute::Use( ssShader* pShader )
{
	if (m_glslID==-1) //获取序号
	{
		m_glslID = pShader->GetAttribLocation(m_glslName.c_str());
	}
	if (m_glslID >= 0) //传递数据到显存
	{
		glEnableVertexAttribArray(m_glslID);
		glVertexAttribPointer(m_glslID, m_size, m_type, GL_FALSE, m_stride, m_data);
	}
}

void ssShaderAttribute::Nonuse()
{
	if (m_glslID >= 0)
	{
		glDisableVertexAttribArray(m_glslID);
	}
}

void ssShaderAttribute::BindData(i32 size, i32 type, i32 stride, const void* data, const char* name)
{
	m_size = size;
	m_type = type;
	m_stride = stride;
	m_data = data;
	m_glslName = name;
}

}
